import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-04-20
 * Time: 9:44
 */

//
//
////    public static void main(String[] args) {
////        // 创建了两个对象，一份存在字符串常量池中，一份存在堆中
////        String s = new String("aa");
////        // 检查常量池中是否存在字符串aa，此处存在则直接返回
////        String s1 = s.intern();
////        String s2 = "aa";
////
////        System.out.println(s == s2);  // false
////        System.out.println(s1 == s2); // true
////    }
//
//public static void main3(String[] args) {
//        String str = new String(new char[]{'h', 'e', 'l', 'l', 'o'});
//        String str2 = new String("hello,world");
//        str2 = str2.intern();
//        String str1 = "hello,world";
//        String str3 = "hello,world";
//        System.out.println(str1==str2);
//        System.out.println(str1==str3);
//        System.out.println(str2==str3);
//        }
//
//
//public static void main2(String[] args) {
//        char[] ch = new char[]{'a', 'b', 'c'};
//        String s1 = new String(ch); // s1对象并不在常量池中
//        s1 = s1.intern();//调用之后，会将s1对象的引用放入到常量池中
//        String s2 = "abc"; // "abc" 在常量池中存在了，s2创建时直接用常量池中"abc"的引用
//        System.out.println(s1 == s2);
//        }
//
//
//
//public static void main1(String[] args) {
//        String str1 = "hello,world";
//        String str2 = new String("hello,world");
//        str2.intern();
//        String str3 = "hello,world";
//
//        }
class Solution {

    private boolean isCharacter(char ch) {
        //判断其字符是否字符为合法字符
        if(ch>='a'&&ch<='z'||ch>=0&&ch<=9) {
            return true;
        }
        return false;
    }
    public boolean isPalindrome(String s) {
        //先将其都变成小写
        s = s.toLowerCase();
        int left =0;//左索引
        int right = s.length()-1;//右索引
        while(left<right) {
            //寻找左边有效字符
            while(left<right&&!isCharacter(s.charAt(left))) {
                left++;
            }
            //寻找右边有效字符
            while(left<right&&!isCharacter(s.charAt(right))) {
                right--;
            }
            //此时已经找到了合法字符我们开始一一比较
            if(s.charAt(left)!=s.charAt(right)) {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}
public class TestDemo {

    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.isPalindrome("A,*&&&&&bBa"));
        Scanner scan = new Scanner(System.in);

    }

    public static void main8(String[] args) {
        String str = "dfghERTYU";
        str=str.toLowerCase();
        System.out.println(str);
    }

    public static void main7(String[] args) {
        //输入一个字符串
        Scanner scan = new Scanner(System.in);
        String str =scan.nextLine();
        //从后往前找空格
        int tmp = str.lastIndexOf(' ',str.length()-1);
        if(tmp<0) {
            tmp=0;
        }else {
            tmp+=1;
        }
        int cnt =0;
        for(int i =tmp;i<str.length();++i) {
            ++cnt;
        }
        System.out.println(cnt);
    }
    public static void main6(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextLine()) {
            String str = scan.nextLine();//输入一个字符串
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < str.length(); ++i) {
                //看一看这个sb里有没有这个字母，如果没有就append拼接上去，如果有不拼接
                String tmp = str.charAt(i) + "";
                String ret = sb.toString();
                if (!ret.contains(tmp)) {
                    sb.append(tmp);
                }
            }
            System.out.println(sb);
        }
    }


    public static String reverse(String str,int left,int right) {
        //将字符串转化成字符数组
        char[] chars = str.toCharArray();
        while(left<right) {
            char tmp = chars[left];
            chars[left] = chars[right];
            chars[right] = tmp;
            left++;
            right--;
        }
        return String.copyValueOf(chars);
    }
    public static void main5(String[] args) {
        Scanner scan = new Scanner(System.in);
        //输入一个字符串
        int ret =scan.nextInt();
        String str = scan.next();
        str= reverse(str,0,ret-1);//左边reverse
        str=reverse(str,ret,str.length()-1);//右边reverse
        str=reverse(str,0,str.length()-1);//整体reverse
        System.out.println(str);
    }

    public static void main1(String[] args) {
        //使用StringBuffer
        StringBuffer stringBuffer = new StringBuffer();
        for(int i =0;i<10;++i) {
            stringBuffer.append("a");
        }
        System.out.println(stringBuffer);
        //使用StringBuilder
        StringBuilder stringBuilder = new StringBuilder();
        for(int i =0;i<10;++i) {
            stringBuilder.append("a");
        }
        System.out.println(stringBuilder);
    }
    //    public static void main(String[] args) {
//        String str = "";
//        for(int i =0;i<10;++i) {
//            str+="a";
//        }
//        System.out.println(str);
//    }
}
